<template>
  <div>
    <div class="header">
      <div class="title"><text>班级管理</text></div>
      <el-form>
        <el-button type="danger" size="small " class="icon el-icon-delete" style="margin-left: 20px;" @click="listdelete">
          删除</el-button>
        <el-button type="primary" size="small " class="icon el-icon-circle-plus-outline" @click="dialogFormVisible=true">
          添加班级</el-button>
          <el-select size="mini" style="margin-left: 20px; width: 150px;" v-model="queryinfo.courseid" placeholder="请选择课程">
            <el-option  v-for="item in coureslist" :key="item.id" :label="item.name" :value="item.id"></el-option>
          </el-select>
        <el-input size="mini"  v-model="queryinfo.name" style="width: 200px; margin-left: 20px;" placeholder="输入班级名称"></el-input>
        <el-button type="primary" size="small " style="margin-left: 10px;" class="icon el-icon-search" @click="gettratelist">查询</el-button>
      </el-form>
    </div>
    <div class="list">
      <el-card class="box-card">
        <el-table :data="tableData" style="width: 100%" @selection-change="handleSelectionChange">
          <el-table-column  width="55">
          </el-table-column>
          <el-table-column prop="name" label="班级名称" width="180">
          </el-table-column>
          <el-table-column prop="coursename" label="课程" width="180">
          </el-table-column>
          <el-table-column prop="teacherslist" label="老师" width="180">
          </el-table-column>
          <el-table-column prop="coursecounts" label="人数" width="180">
          </el-table-column>
          <el-table-column prop="endcourses" label="计划课时">
          </el-table-column>
          <el-table-column prop="schcourses" label="已排课时" width="180">
          </el-table-column>
          <el-table-column prop="students" label="已上课时" width="180">
          </el-table-column>
          <el-table-column fixed="right" label="操作" width="100">
            <template #default="scope">
              <el-button type="text" size="small" @click="paike(scope.row)">排课</el-button>
              <el-button type="text" size="small" @click="updates(scope.row)">编辑</el-button>
              <el-button type="text" size="small" @click="kebiao(scope.row)">课表</el-button>
              <el-button type="text" size="small" @click="finddelete(scope.row)">删除</el-button>
            </template>
          </el-table-column>
        </el-table>
        <el-pagination
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="queryinfo.page"
        :page-sizes="[1, 5, 10, 100]"
        :page-size="queryinfo.psize"
        layout="total, sizes, prev, pager, next, jumper"
        :total="total">
      </el-pagination>
      </el-card>
    </div>
    <!-- 添加 -->
    <el-dialog title="班级添加" v-model="dialogFormVisible">
      <el-form ref='formtrate' :rules="rules"  :label-position="labelPosition" size="small" label-width="80px" :model="addlist">
        <el-form-item label="所选课程" prop="courseid" style="width: 290px;">
          <el-select v-model="addlist.courseid" placeholder="请选择课程">
            <el-option v-for="item in coureslist" :key="item.id" :label="item.name" :value="item.id"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="班级名称" prop="name" style="width: 400px;">
          <el-input v-model="addlist.name"></el-input>
        </el-form-item>
        <el-form-item label="计划课时" prop="coursecounts" style="width: 400px;">
          <el-input v-model="addlist.coursecounts"></el-input>
        </el-form-item>
        <el-form-item label="开班日期" prop="startdate" style="width: 290px;">
          <el-date-picker  v-model="addlist.startdate" format="YYYY-MM-DD"
                      value-format="YYYY/MM/DD"  type="date" placeholder="选择日期">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="结班日期"  prop="enddate" style="width: 290px;">
          <el-date-picker v-model="addlist.enddate" format="YYYY-MM-DD"
                      value-format="YYYY/MM/DD" type="date" placeholder="选择日期">
          </el-date-picker>
        </el-form-item>
      </el-form>
      <template #footer>
        <span class="dialog-footer">
          <el-button @click="dialogFormVisible = false">取 消</el-button>
          <el-button type="primary" @click="trateinsert('formtrate')">确 定</el-button>
        </span>
      </template>
    </el-dialog>
    <!-- 修改 -->
    <el-dialog title="更新" v-model="dialogFormVisibleupdate">
      <el-form ref='formtrateupdate' :rules="rules"  :label-position="labelPosition" size="small" label-width="80px" :model="addlist">
        <el-form-item label="所选课程"  style="width: 290px;">
          <el-select v-model="update.courseid" placeholder="请选择课程">
            <el-option v-for="item in coureslist" :key="item.id" :label="item.name" :value="item.id"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="班级名称" prop="" style="width: 400px;">
          <el-input v-model="update.name"></el-input>
        </el-form-item>
        <el-form-item label="计划课时" prop="" style="width: 400px;">
          <el-input v-model="update.coursecounts"></el-input>
        </el-form-item>
        <el-form-item label="开班日期" prop="" style="width: 290px;">
          <el-date-picker  v-model="update.startdate" format="YYY-MM-DD" value-format="YYYY/MM/DD" type="date" placeholder="选择日期">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="结班日期"  prop="" style="width: 290px;">
          <el-date-picker v-model="update.enddate" format="YYY-MM-DD" value-format="YYYY/MM/DD" type="date" placeholder="选择日期">
          </el-date-picker>
        </el-form-item>
      </el-form>
      <template #footer>
        <span class="dialog-footer">
          <el-button @click="dialogFormVisibleupdate = false">取 消</el-button>
          <el-button type="primary" @click="updatex('formtrateupdate')">确 定</el-button>
        </span>
      </template>
    </el-dialog>
    <!-- 排课 -->
    <el-dialog title="班级排课"  v-model="dialogFormVisibleke">
      <el-form ref="form" :model="insertpai" >
           <div class="bba" style="width: 100%; height: 100px;">
              <!-- 主讲老师 -->
              <div class="acc">
                <el-form-item label="主讲老师" size="small"><span style="color: cornflowerblue;" @click="zhujiao">添加老师</span>
                  <el-select v-model="insertpai.teacherid" placeholder="请选择">
                    <el-option v-for="item in teacherlist" :key="item.id" :label="item.name" :value="item.id"></el-option>
                  </el-select>
                </el-form-item>
              </div>
              <!-- 助教老师 -->
              <div class="acc" v-show="shhid">
                <el-form-item label="助教老师" size="small">
                  <el-select v-model="insertpai.assistant" placeholder="请选择">
                    <el-option v-for="item in zhujiaolist" :key="item.id" :label="item.name" :value="item.id"></el-option>
                  </el-select>
                </el-form-item>
              </div>
              <!-- 教室 -->
              <div class="acc">
                <el-form-item label="教室" size="small">
                  <el-select v-model="insertpai.classrooms" placeholder="请选择">
                    <el-option v-for="item in classroomlists" :key="item.id" :label="item.name" :value="item.id"></el-option>
                  </el-select>
                </el-form-item>
              </div>
              <!-- 单节课扣学员课时 -->
              <div class="acc">
                <el-form-item  label="单节课扣学员课时" size='small'>
                  <el-input v-model="insertpai.pricecounts"></el-input>
                </el-form-item>
              </div>
          </div>

          <div class="bba-ctnter">
               <div class="kpl" style="display:flex; height: 20%; align-items: center; font-size:15px;">
                <el-menu :default-active="activeIndex"  class="el-menu-demo" mode="horizontal" >
                  <el-menu-item index="1"  @click="dan">单次排课</el-menu-item>
                  <el-menu-item index="2"  @click="pl">批量排课</el-menu-item>
                </el-menu>
              </div>
               <div class="kpl" style="display: flex; height: 40%;">
                  <div style="width: 40%; height: 100%;">
                    <el-form-item label="开课日期" style="margin-top: 10%;" required>
                      <el-col :span="11">
                        <el-form-item prop="date1" size="amall" >
                          <el-date-picker type="date" format="YYYY-MM-DD"  value-format="YYYY-MM-DD" v-model="insertpai.begindate" placeholder="选择日期"  style="width: 100%;"></el-date-picker>
                        </el-form-item>
                      </el-col>
                    </el-form-item>
                  </div>
                  <div v-show="plsh" style="display: flex; width: 60%; height: 100%;">
                    <div style="flex: 1;">
                      <el-form-item label="结课方式">
                        <el-radio-group format="YYYY-MM-DD"  value-format="YYYY-MM-DD"  v-model="insertpai.jsfs" style="margin-right: 17%;">
                          <el-radio   label="按课结"  @change="rightx"></el-radio>
                          <el-radio   label="按日期结" @change="rights"></el-radio>
                        </el-radio-group>
                      </el-form-item>
                    </div>
                    <div v-show="zong" style="flex: 1;">
                      <el-form-item label="排课总数" size='small'>
                        <el-input v-model="insertpai.coursescount"></el-input>
                      </el-form-item>
                    </div>
                    <div  v-show="jie" style="flex: 1;">
                      <el-form-item label="结课日期" size='small'>
                        <el-form-item prop="date1" size="amall" >
                          <el-date-picker format="YYYY-MM-DD"  value-format="YYYY-MM-DD" v-model="insertpai.enddate" type="date" placeholder="选择日期"  style="width: 100%;"></el-date-picker>
                        </el-form-item>
                      </el-form-item>
                    </div>
                  </div>
               </div>
               <div class="kpl" style="height: 40%; width: 100%;"></div>
          </div>

          <div v-show="datadata" class="back" style="margin-top: 10px; width: 100%; background-color: #fff;">
            <el-form-item label="上课时间">
              <el-col :span="11" size="small">
                <el-time-select v-model="begintime0" placeholder="选择时间"  style="width: 100%;"></el-time-select>
              </el-col>
              <el-col class="line" :span="2">-</el-col>
              <el-col :span="11">
                <el-time-select v-model="endtime0" placeholder="选择时间"  style="width: 100%;"></el-time-select>
              </el-col>
            </el-form-item>
          </div>

          <!-- 按日期 -->
          <div v-show="data" style="width: 100%; background-color: #fff;">
            <el-form-item label="星期选择">
              <el-checkbox-group v-model="week">
                <el-checkbox label="1" @change="sunday" name="type">星期日</el-checkbox>
                <el-checkbox label="2" @change="Monday" name="type">星期一</el-checkbox>
                <el-checkbox label="3" @change="Tuesday" name="type">星期二</el-checkbox>
                <el-checkbox label="4" @change="Wednesday" name="type">星期三</el-checkbox>
                <el-checkbox label="5" @change="Thursday" name="type">星期四</el-checkbox>
                <el-checkbox label="6" @change="Friday" name="type">星期五</el-checkbox>
                <el-checkbox label="7" @change="Saturday" name="type">星期六</el-checkbox>
              </el-checkbox-group>
            </el-form-item>
          </div>
          <div class="classes" style="width: 100%;">
              <!-- <div class="class"> -->
                 <div class="class-chali" v-show="weeks.weekri" >
                   <div style="height: 40%; display: flex; align-items: center;"><span>周日时间</span></div>
                    <el-form-item  style="display:flex;" label="">
                    <el-col :span="11">
                      <el-time-select size="small" v-model="begintime1" placeholder="选择时间"  style="width: 100%;"></el-time-select>
                    </el-col>
                    <!-- <el-col class="line" :span="2">-</el-col> -->
                    <el-col :span="11">
                      <el-time-select v-model="endtime1" size="small" placeholder="选择时间"  style=" width: 100%;"></el-time-select>
                    </el-col>
                  </el-form-item>
                 </div>
                 
                 <div class="class-chali" v-show="weeks.weekyi" >
                  <div style="height: 40%; display: flex; align-items: center;"><span>周一时间</span></div>
                  <el-form-item  style="display:flex;" label="">
                  <el-col :span="11">
                    <el-time-select v-model="begintime2" size="small" placeholder="选择时间"  style="width: 100%;"></el-time-select>
                  </el-col>
                  <!-- <el-col class="line" :span="2">-</el-col> -->
                  <el-col :span="11">
                    <el-time-select v-model="endtime2" size="small" placeholder="选择时间"  style=" width: 100%;"></el-time-select>
                  </el-col>
                </el-form-item>
                 </div>
              <!-- </div> -->

              <!-- <div class="class"> -->
                <div class="class-chali" v-show="weeks.weeker">
                  <div style="height: 40%; display: flex; align-items: center;"><span>周二时间</span></div>
                  <el-form-item  style="display:flex;" label="">
                  <el-col :span="11">
                    <el-time-select v-model="begintime3"  size="small" placeholder="选择时间"  style="width: 100%;"></el-time-select>
                  </el-col>
                  <!-- <el-col class="line" :span="2">-</el-col> -->
                  <el-col :span="11">
                    <el-time-select v-model="endtime3" size="small" placeholder="选择时间"  style=" width: 100%;"></el-time-select>
                  </el-col>
                </el-form-item>
                </div>

                <div class="class-chali"  v-show="weeks.weeksan">
                  <div style="height: 40%; display: flex; align-items: center;"><span>周三时间</span></div>
                    <el-form-item  style="display:flex;" label="">
                    <el-col :span="11">
                      <el-time-select v-model="begintime4"  size="small" placeholder="选择时间"  style="width: 100%;"></el-time-select>
                    </el-col>
                    <!-- <el-col class="line" :span="2">-</el-col> -->
                    <el-col :span="11">
                      <el-time-select v-model="endtime4" size="small" placeholder="选择时间"  style=" width: 100%;"></el-time-select>
                    </el-col>
                  </el-form-item>
                </div>
              <!-- </div> -->

              <!-- <div class="class"> -->
                <div class="class-chali"  v-show="weeks.weeksi">
                  <div style="height: 40%; display: flex; align-items: center;"><span>周四时间</span></div>
                  <el-form-item  style="display:flex;" label="">
                  <el-col :span="11">
                    <el-time-select v-model="begintime5"  size="small" placeholder="选择时间"  style="width: 100%;"></el-time-select>
                  </el-col>
                  <!-- <el-col class="line" :span="2">-</el-col> -->
                  <el-col :span="11">
                    <el-time-select v-model="endtime5" size="small" placeholder="选择时间"  style=" width: 100%;"></el-time-select>
                  </el-col>
                </el-form-item>
                </div>

                <div class="class-chali"  v-show="weeks.weekwu">
                  <div style="height: 40%; display: flex; align-items: center;"><span>周五时间</span></div>
                    <el-form-item  style="display:flex;" label="">
                    <el-col :span="11">
                      <el-time-select v-model="begintime6" size="small" placeholder="选择时间"  style="width: 100%;"></el-time-select>
                    </el-col>
                    <!-- <el-col class="line" :span="2">-</el-col> -->
                    <el-col :span="11">
                      <el-time-select v-model="endtime6" size="small" placeholder="选择时间"  style=" width: 100%;"></el-time-select>
                    </el-col>
                  </el-form-item>
                </div>
              <!-- </div> -->

              <!-- <div class="class"> -->
                <div class="class-chali"  v-show="weeks.weekliu">
                  <div style="height: 40%; display: flex; align-items: center;"><span>周六时间</span></div>
                  <el-form-item  style="display:flex;" label="">
                  <el-col :span="11">
                    <el-time-select v-model="begintime7" size="small" placeholder="选择时间"  style="width: 100%;"></el-time-select>
                  </el-col>
                  <!-- <el-col class="line" :span="2">-</el-col> -->
                  <el-col :span="11">
                    <el-time-select v-model="endtime7" size="small" placeholder="选择时间"  style=" width: 100%;"></el-time-select>
                  </el-col>
                </el-form-item>
                </div>

                <!-- <div class="class-chali">
                </div> -->
              <!-- </div> -->

          </div>
           <!-- 添加学员 -->
           <div class="" style="display: flex; width: 50%; margin-top: 10px;">
            <div style="font-weight: bold;">选择学员(0)</div>
            <div class="icon el-icon-user-solid" style="margin-left: 30%;">
              <span style="color:  cornflowerblue;" @click="dialogFormVisibleinsert=true"> 添加学员</span>
            </div>
         </div>
         <el-dialog title="添加学员" v-model="dialogFormVisibleinsert">
             <el-transfer
             v-model="val"
             style="text-align: left;"
             filterable
             :filter-method="filterMethod"
             filter-placeholder="请输入城市拼音"
             :data="datas"
            />
          <template #footer>
            <span class="dialog-footer">
              <el-button @click="dialogFormVisibleinsert = false">取 消</el-button>
              <el-button type="primary" @click="chuan">确 定</el-button>
            </span>
          </template>
        </el-dialog>


      </el-form>
      <template #footer>
        <span class="dialog-footer">
          <el-button @click="dialogFormVisibleke = false">取 消</el-button>
          <el-button type="primary" @click="serve">确 定</el-button>
        </span>
      </template>
    </el-dialog>
    <!-- 课表 -->
    <el-dialog title="课表" width="90%"  v-model="dialogFormVisiblebiao">
        <div style="width: 100%; display: flex; justify-content: space-between;">
         <div class="left" style="border-radius: 10px; height: 650px; width: 21%; background-color: #fff;">
          <!-- 班级名称 -->
             <div class="left-title" style="width: 100%; height: 6.5%; background-color: #1890ff; border-top-left-radius: 10px; border-top-right-radius: 10px;">
                <span style="margin-left: 5%; color: #fff;">{{kebiaolist.name}}</span>
             </div>
             <!-- 班级信息 -->
             <div class="left-trate">
               <div class="left-text"><span style="margin-left: 5%;">课程 : <span style="color: #333;">{{kebiaolist.coursename}}</span></span></div>
               <div class="left-text"><span style="margin-left: 5%;">老师 : <span style="color: #333;">{{}}</span></span></div>
               <div class="left-text"><span style="margin-left: 5%;">人数 : <span style="color: #333;">{{kebiaolist.coursecounts}}</span></span></div>
             </div>
             <!-- 进度条 -->
             <div style="display: flex; justify-content: center; margin-top: 4%; width: 100%; height: 4%; ">
               <div style="width: 93%;">
                <el-progress  :text-inside="true" :stroke-width="24" :percentage="kebiaolist.schcourses" status="success"></el-progress>
               </div>
             </div>
             <!-- 以上课节 -->
             <div style="border-bottom: 15px solid rgba(245, 245, 245, 0.979); width: 100%; height: 7%; display: flex; justify-content: center; margin-top: 2%;"> 
                 <div style=" display: flex; align-items: center; justify-content: space-between; width: 93%; height: 100%;">
                   <div>已上{{kebiaolist.students}}节课</div>
                   <div>已排{{kebiaolist.schcourses}}节课</div>
                  </div>
             </div>
             <!-- 班级学员 -->
             <div class="trate">
               <div style=" display: flex; justify-content: center; width: 100%; height: 11%; background-color: #fff;">
                 <div style="border-bottom: 2px solid rgb(189, 185, 185); display: flex; justify-content: space-between; align-items: center; width: 93%; height: 100%;">
                    <div>班级人数（{{kebiaolist.coursecounts}}）</div>
                    <div style="color: cornflowerblue;" class="el-icon-user-solid ">+</div>

                 </div>
              </div>
             </div>
         </div>

         <div class="right">
          <el-tabs style="margin-top: 2%;" v-model="activeName">
            <el-tab-pane label="单次排课" name="second">
               <div style="width: 100%; height: 100%; background-color: darkgoldenrod;">
                <el-calendar>
                  <template #dateCell="{data}">
                      <div style="text-align:center; font-size: 18px;">
                        {{data.day.substr(8,2)}}
                        <div v-for="item in datetrate" :key="item.id"  style="margin-top: 10px;">
                          <div v-if="item.coursedate==data.day" style="display: flex; width: 95px;border-radius: 3px; height: 45px; background-color: rgb(247, 247, 247);">
                              <div style="width: 7%; border-top-left-radius: 3px; border-bottom-left-radius: 3px; height: 100%; background-color: cornflowerblue;"></div>
                              <div style="width: 90%; margin-left: 3%; height: 100%;">
                                 <div style="display: flex; align-items: center; width: 100%; height: 50%;  font-size: 12px; ">{{item.coursename}}</div>
                                 <div style="display: flex; width: 100%; height: 50%;">
                                   <div style="width: 50%; height: 100%; display: flex; align-items: center; font-size: 12px;">{{item.starttime.substr(11,5)}}</div>
                                   <div style="width: 50%; height: 100%; display: flex; align-items: center; font-size: 12px; ">{{item.teachername}}</div>
                                 </div>
                              </div>
                         </div>
                     </div>
                      </div>
                  </template>
                </el-calendar>
               </div>
            </el-tab-pane>
            <el-tab-pane label="批量排课" name="first ">啥也没有...</el-tab-pane>
          </el-tabs>
         </div>
      </div>
      <template #footer>
        <!-- <span class="dialog-footer">
          <el-button @click="dialogFormVisiblebiao = false">取 消</el-button>
          <el-button type="primary" @click="dialogFormVisiblebiao = false">确 定</el-button>
        </span> -->
      </template>
    </el-dialog>

  </div>
</template>
<script>
  export default {
    data() {
      return {
        //穿梭框
        val:[],
        datas:[],
        dataname:[],//学员名称
        //
        multipleSelection: [],
        dialogFormVisible: false,//添加
        dialogFormVisibleupdate:false,//修改
        dialogFormVisibleke:false,//排课
        dialogFormVisibleinsert:false,//添加学员
        dialogFormVisiblebiao:false,//课表
        activeName: 'second',//课表单次排课
        value: new Date(),
        labelPosition:'right',
        activeIndex:'1',
        tableData: [],
        queryinfo:{
          page:1,
          psize:3,
          name:'',
          courseid:''
        },
        total:0,
        coureslist: [],
        addlist: {
          name:''
        },
        formadd:{
          type:[],
        },
        soulist:[],
        shhid:false, //  助教老师显示/隐藏
        plsh:false, //批量排课显示/隐藏
        data:false,//按日期显示/隐藏
        datadata:true,//上课时间显示/隐藏
        zong:true,//排课总数
        jie:false,//结课日期
        weeks:{
          weekri:false,//周日
          weekyi:false,//周一
          weeker:false,//周二
          weeksan:false,//周三
          weeksi:false,//周四
          weekwu:false,//周五
          weekliu:false,//周六
        },
        teacherlist:[],// 主讲老师
        classroomlists:[],//教室
        zhujiaolist:[],
        insertpai:{
          // studentid:'',//学生ID
          classid:'',//班级ID
          // courseid:'',//课程ID
          teacherid:'',//主讲老师ID
          assistant:'', // 助教老师ID
          classrooms:'',// 教室ID
          addtype:'one',
          pricecounts:'2',// 单节课扣学员课时
          begindate:'',//开课日期
          jsfs:'按课结',//结课方式
          coursescount:'1',//排课总数
          studentlist:[],//学员列表
          weektime:[],//上课时间数组
          enddate:'',//结课日期
        },
        week:[],
        begintime0:'',
        endtime0:'',
        begintime1:'',
        endtime1:'',
        begintime2:'',
        endtime2:'',
        begintime3:'',
        endtime3:'',
        begintime4:'',
        endtime4:'',
        begintime5:'',
        endtime5:'',
        begintime6:'',
        endtime6:'',
        begintime7:'',
        endtime7:'',

        kebiaolist:[],
        id:{
          classid:'',
          courseid:'',
        },

        datetrate:[],
        update:{
            id:'',
            courseid:'',
            name:'',
            coursecounts:'',
            startdate:'',
            enddate:''
        },
        rules:{
          name:[
          { required: true, message: '请输入名称', trigger: 'blur' },
           { min:1, max: 6, message: '1到6个字符', trigger: 'blur' }
          ],
          coursecounts:[
          { required: true, message: '请输入课时', trigger: 'blur' },
           { min:1, max: 2, message: '1到2个字符纯数字', trigger: 'blur' }
          ],
          startdate:[
          { required: true, message: '日期不能为空', trigger: 'blur' },
          ],
          enddate:[
           { required: true, message: '日期不能为空', trigger: 'blur' },
          ]
        }
      }
    },
    created() {
      this.gettratelist()
      this.teacher()
      this.getcoures()
      this.classroomlist()
      this.xuename()
      this.zj()
      
    },
    methods: {
       // 排课
       paike(row){
         console.log(row)
         this.dialogFormVisibleke=true
         this.insertpai.classid=row.id
       },       

       async serve(){
         this.week.forEach(item=>{
           console.log(item)
           if(item==1){
            let obj={"week":1,"begintime":this.begintime1,"endtime":this.endtime1}
            this.insertpai.weektime.push(obj)
         }else if(item==2){
          let obj={"week":2,"begintime":this.begintime2,"endtime":this.endtime2}
            this.insertpai.weektime.push(obj)
         }else if(item==3){
          let obj={"week":3,"begintime":this.begintime3,"endtime":this.endtime3}
            this.insertpai.weektime.push(obj)
         }else if(item==4){
          let obj={"week":4,"begintime":this.begintime3,"endtime":this.endtime3}
            this.insertpai.weektime.push(obj)
         }else if(item==5){
          let obj={"week":5,"begintime":this.begintime3,"endtime":this.endtime3}
            this.insertpai.weektime.push(obj)
         }else if(item==6){
          let obj={"week":6,"begintime":this.begintime3,"endtime":this.endtime3}
            this.insertpai.weektime.push(obj)
         }else if(item==7){
          let obj={"week":7,"begintime":this.begintime3,"endtime":this.endtime3}
            this.insertpai.weektime.push(obj)
         }
         })
        if(this.week==0){
          let obj={"week":0,"begintime":this.begintime0,"endtime":this.endtime0}
          this.insertpai.weektime.push(obj)
        }
         const {data:res} = await this.$http.post('http://www.eshareedu.cn/edusystems/api/coursetables/add',this.insertpai)
        //  console.log(res)
        if(res.errCode==10000){
          this.$message.success('排课成功')
          this.dialogFormVisibleke=false
          this.gettratelist()
        }else{
          this.$message.error('排课失败')
        }
       },

      chuan(){
        console.log(this.val)
      },
       // 添加学员数据
       async xuename(){
        const {data:res} = await this.$http.get('http://www.eshareedu.cn/edusystems/api/students/searchForConsumed')
        let data=[]
        res.data.list.forEach((item,i)=>{
           data.push({
             label:item.name,
             key:item.id
           })
        })
        this.datas=data
      },
     async kebiao(row){
        console.log(row)
        this.id.classid=row.id
        this.id.courseid=row.courseid
        this.dialogFormVisiblebiao=true
        this.kebiaolist=row
        const {data:res} = await this.$http.get('http://www.eshareedu.cn/edusystems/api/coursetables/search',{params:this.id})
        this.datetrate=res.data.list
        console.log(this.datetrate)
      },
      
      async huizong(){
        
      },
     
        
     
      // 星期日
      sunday(){
        this.weeks.weekri=!this.weeks.weekri
      },
      // 星期一
      Monday(){
        this.weeks.weekyi=!this.weeks.weekyi
      },
      // 星期二
      Tuesday(){
        this.weeks.weeker=!this.weeks.weeker
      },
      // 星期三
      Wednesday(){
        this.weeks.weeksan=!this.weeks.weeksan
      },
      // 星期四
      Thursday(){
        this.weeks.weeksi=!this.weeks.weeksi
      },
      // 星期五
      Friday(){
        this.weeks.weekwu=!this.weeks.weekwu
      },
      // 星期六
      Saturday(){
        this.weeks.weekliu=!this.weeks.weekliu
      },
      // 按课
      rightx(){
        this.datadata=true
        this.data=false
        this.zong=true
        this.jie=false
      },
      // 按日期
      rights(){
        this.datadata=false
        this.data=true
        this.jie=true
        this.zong=false
      },
      // 单次排课
      dan(){
        this.plsh=false
        this.data=false
        this.datadata=true
        this.insertpai.addtype='one'
      },
      // 批量
      pl(){
        this.insertpai.addtype='more'
       this.plsh=true
      },
      //  助教老师显示/隐藏
      zhujiao(){
        this.shhid=!this.shhid
      },
      // 主讲老师
      async teacher(){
        const {data:res} = await this.$http.get('http://www.eshareedu.cn/edusystems/api/teachers/list?cat=0')
        this.teacherlist=res.data.list
      },
      // 教室
      async classroomlist(){
        const {data:res} = await this.$http.get('http://www.eshareedu.cn/edusystems/api/classes/list')
        // console.log(res)
        this.classroomlists=res.data.list
        // console.log(this.classroomlists)
      },
      //助教老师
      async zj(){
        const {data:res} = await this.$http.get('http://www.eshareedu.cn/edusystems/api/teachers/list?cat=2')
        this.zhujiaolist=res.data.list
      },
     
      // 分页
      handleSizeChange(val) {
        this.queryinfo.psize=val
        this.gettratelist()
        // console.log(`每页 ${val} 条`);
      },
      handleCurrentChange(val) {
        this.queryinfo.page=val
        this.gettratelist()
        // console.log(`当前页: ${val}`);
      },
      // 更新
      updates(val){
      //  console.log(val)
       this.dialogFormVisibleupdate=true
       this.update.id=val.id
       this.tableData.forEach(item=>{
        //  console.log(item)
         if(val.id==item.id){
            this.update.courseid=item.courseid
            this.update.name=item.name
            this.update.coursecounts=item.coursecounts
            this.update.startdate=item.startdate
            this.update.enddate=item.enddate
         }
        //  console.log(this.update)
       })
      },
     async updatex(){
        const {data:res} = await this.$http.post('http://www.eshareedu.cn/edusystems/api/classes/add',this.update)
        // console.log(res)
        if(res.errCode==10000){
          this.dialogFormVisibleupdate=false
          this.$message.success('更新成功')
          this.gettratelist()
        }else{
          this.$message.error('更新失败')
        }
      },
      // 添加
      async trateinsert() {
        const token = sessionStorage.getItem('access_token')
        const {
          data: res
        } = await this.$http.post('http://www.eshareedu.cn/edusystems/api/classes/add', this.addlist, {
          headers: {
            token
          }
        })
        console.log(this.addlist)
        if(res.errCode==10000){
          this.$message.success('添加成功')
          this.dialogFormVisible=false
          this.gettratelist()
        }else{
          this.$message.error('添加失败')
        }
      },
      // 课程管理
      async getcoures() {
        const token = sessionStorage.getItem('access_token')
        // console.log(token)
        const {
          data: res
        } = await this.$http.get('http://www.eshareedu.cn/edusystems/api/courses/list', {
          headers: {
            token
          }
        })
        //  console.log(res)
        if (res.errCode == 10000) {
          this.coureslist = res.data.list
        }
        // console.log(this.coureslist)
      },
      async gettratelist() {
        const token = sessionStorage.getItem('access_token')
        // console.log(token)
        const {
          data: res
        } = await this.$http.get('http://www.eshareedu.cn/edusystems/api/classes/list',{params:this.queryinfo})
        //  console.log(res)
        if (res.errCode == 10000) {
          this.tableData = res.data.list
          this.total=res.data.counts
        }
      },
      // 批量删除
      handleSelectionChange(val) {
        this.multipleSelection = val;
        console.log(val)
      },
      // 单条数据删除
      async finddelete(item) {
        let self = this
       
      const cath = await this.$confirm('此操作将永久删除该文件, 是否继续?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).catch(error => {
           return error
        })
        // console.log(cath)
        if(cath=='confirm'){
          const token = sessionStorage.getItem('access_token')
          const {data:res} = await this.$http.get('http://www.eshareedu.cn/edusystems/api/classes/delete?id='+item.id,{headers:{token}})
          // console.log(res)
          if(res.errCode==10000){
            this.$message.success('删除成功')
            this.gettratelist()
          }else{
            this.$message.error('删除失败')
          }
        }
        if(cath=='cancel'){
          this.$message.info('以取消删除')
        }
      }
    },
  }

</script>

<style scoped>
  /* 课表 */
  .right{
    width: 78%;
    height: 670px;
    background-color: #fff;
  }
  .trate{
    width: 100%;
    height: 58%;
    background-color: rgba(245, 245, 245, 0.979);
    margin-top: 5%;
    border-bottom-left-radius: 10px;
    border-bottom-right-radius:10px ;
  }
  .left-title{
     display: flex;
     align-items: center;
  }
  .left-trate{
    width: 100%;
    height: 20%;
    /* background-color: forestgreen; */
    display: flex;
    flex-direction: column;
  }
  .left-text{
    flex: 1;
    width: 100%;
    font-size: 15px;
    color:black;
    font-weight: bold;
    /* background-color: blanchedalmond; */
    display: flex;
    align-items: center;
  }
  /* // */
  /* 周 */
  .classes{
    display: flex;
    flex-wrap: wrap;
  }
  /* .class{
    width: 100%;
    height: 80px;
    background-color: darkgreen;
    margin-top: 5px;
    display: flex;
  } */
  .class-chali{
    /* flex: 1; */
    height: 80px;
    width: 50%;
    height: 100%;
    /* background-color: rgb(170, 167, 170); */
  }
  /* 周 */
  .bba-ctnter{
    width: 100%;
    /* height:250px; */
    /* background-color: cornflowerblue; */
    display: flex;
    flex-direction: column;
  }
 
  .bba{
    display: flex;
    justify-content: space-between;
  }
  .acc{
    width: 24%;
    height: 100%;
    /* background-color: rgb(163, 160, 159); */
  }
  .header {
    width: 100%;
    display: flex;
    height: 50px;
    border-top-left-radius: 5px;
    border-top-right-radius: 5px;
    box-shadow: 1px 1px 3px 1px rgb(200, 226, 241);
    background-color: rgb(233, 237, 240);
    align-items: center;
  }

  .title {
    width: 100px;
    height: 100%;
    border-top-left-radius: 5px;
    border-bottom-left-radius: 5px;
    background-color: rgb(198, 219, 243);
    text-align: center;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 17px;
    font-weight: bold;
  }

  .list {
    margin-top: 10px;
  }

</style>
